﻿using Box2DSharp.Dynamics;

namespace TrinityEngine
{
    public class Rigidbody2D : PhysicsBody
    {
        private Body _rigid;

        public Collider2D collider;

        public BodyType type
        {
            get { return _rigid.BodyType; }
            set { _rigid.BodyType = value; }
        }

        /*public Rigidbody2D(Collider2D collider)
        {
            collider.rigidbody = _rigid;
            this.collider = collider;

            BodyDef def = new BodyDef()
            {
                BodyType = BodyType.DynamicBody
            };

            _rigid = Engine.Instance.world.CreateBody(def);
            _rigid.CreateFixture(this.collider.GetShape(), 1.0f);
        }

        protected override void Awake()
        {
            _rigid.SetTransform(transform.position.Xy, transform.rotation.Z);
        }

        protected override void OnEnable()
        {
            _rigid.IsEnabled = true;
        }

        protected override void OnDisable()
        {
            _rigid.IsEnabled = false;
        }

        protected override void OnDestroy()
        {
            _rigid.IsEnabled = false;
            Engine.Instance.world.DestroyBody(_rigid);
        }
*/
        protected override void FixedUpdate()
        {
           /* transform.position = _rigid.GetPosition();
            transform.rotation = _rigid.GetAngle();*/
        }
    }
}
